/** file Slide.cpp
    author belot.nicolas
*/

#include "Slide.h"

namespace libtrckr {

Slide::Slide():c(1.0,1024){
	duration = elapsed = speed=.0;
	max_ratio=1.;
	
}

Slide::Slide(const Slide &s):c(s.c){
	duration = s.duration;
	elapsed = s.elapsed;
	speed = s.speed;
	max_ratio=s.max_ratio;
}

Slide::~Slide(){

}

void Slide::Tune(DynArray<double> conf){
	max_ratio=conf[0]; //where di we go.
	duration=conf[1];//how long
	speed = (1. - max_ratio) / duration;//technically, we accelerate...
}

Buffer& Slide::apply(Buffer&b, int*size){
	//calculate new ratio
	double ratio = 1.0 + (speed * elapsed);
	Buffer b2(*size);
	for(uint i=0;i<*size;i++){
		b2[i]=b[i];
	}
	c.ratio(ratio);
	int retsize = c.convert(b2,b);
	*size=retsize;
	elapsed += *size;
	return b;
}


}

